

<template tag="以下文档内容为hycli自动生成">
  <el-dialog
    v-model="conf.visible"
    
    :title="title"
    :width="conf.width"
    draggable
    align-center="true"
    :close-on-click-modal="false"
  >
<el-form :model="form"  ref="form" :rules="rules_aaabz">
    <el-row>
    <el-col :span="12">
    <!-- {"index":122,"raw":"plan_id","name":"plan_id","cname":"PlanId","type":{"raw":"varchar2(32)","name":"varchar2","len":32,"dlen":0},"defValue":"","allowNull":false,"constraints":["l","le","c","q","u","sl(dev_plan,-,#lob_id)","tp(multiselect)","v","show(m,l)","lw(200)"],"desc":{"raw":"上线计划","name":"上线计划"}} -->
    <!--上线计划 多选控件 --> 
    <el-form-item prop="plan_id" label="上线计划" label-width="100px" label-position="right">
      <el-select style="width: 100%"   v-model="form.plan_id" clearable multiple  collapse-tags 
      collapse-tags-tooltip
        placeholder="请选择上线计划">
        <el-option v-for="item in plan_idList" :key="item.value" :label="item.name" :value="item.value" />
      </el-select>
    </el-form-item>
    </el-col>
    <el-col :span="12">
    <!-- {"index":123,"raw":"deloy_version","name":"deloy_version","cname":"DeloyVersion","type":{"raw":"varchar2(32)","name":"varchar2","len":32,"dlen":0},"defValue":"","allowNull":false,"constraints":["l","le","c","u","v","color"],"desc":{"raw":"版本","name":"版本"}} -->
    <!--版本 输入控件 -->
    <el-form-item prop="deloy_version" label="版本" label-width="100px" label-position="right">
      <el-input clearable style="width: 100%" v-model="form.deloy_version"  maxlength="32" 
      :rows="0"  placeholder="请输入版本"  />
      </el-form-item>
    </el-col>
    <el-col :span="24">
    <!-- {"index":124,"raw":"name","name":"name","cname":"Name","type":{"raw":"varchar2(64)","name":"varchar2","len":64,"dlen":0},"defValue":"","allowNull":false,"constraints":["l","le","c","q","u","DN","lw(120)","v","x","rows(1)","#like"],"desc":{"raw":"名称","name":"名称"}} -->
    <!--名称 输入控件 -->
    <el-form-item prop="name" label="名称" label-width="100px" label-position="right">
      <el-input clearable style="width: 100%" v-model="form.name"  maxlength="64" 
      :rows="1"  type="textarea" show-word-limit  placeholder="请输入名称"  />
      </el-form-item>
    </el-col>
    <el-col :span="12">
    <!-- {"index":125,"raw":"deloy_start","name":"deloy_start","cname":"DeloyStart","type":{"raw":"date","name":"date","len":0,"dlen":0},"defValue":"","allowNull":false,"constraints":["l(MM/dd HH)","le","c","u","v(MM/dd HH点)","q","tp(daterange,q)","tp(datetime,c-u,yyyy/MM/dd 18:00:00)"],"desc":{"raw":"预计开始","name":"预计开始"}} -->
    <!--预计开始 日期控件 -->
    <el-form-item prop="deloy_start" label="预计开始" label-width="100px" label-position="right">
      <el-date-picker style="width: 100%" v-model="form.deloy_start" clearable type="datetime"
        placeholder="请选择预计开始" format="YYYY-MM-DD HH:mm:ss" value-format="YYYY-MM-DD HH:mm:ss" 
         :default-time="new Date($theia.str.dateFormat(new Date(),'yyyy/MM/dd 18:00:00'))"/>
    </el-form-item>
    </el-col>
    <el-col :span="12">
    <!-- {"index":126,"raw":"deloy_finish","name":"deloy_finish","cname":"DeloyFinish","type":{"raw":"date","name":"date","len":0,"dlen":0},"defValue":"","allowNull":false,"constraints":["l(MM/dd HH)","le","c","u","v(MM/dd HH点)","q","tp(daterange,q)","tp(datetime,c-u,yyyy/MM/dd 18:00:00)","lw(120)","show(m,l)"],"desc":{"raw":"预计完成","name":"预计完成"}} -->
    <!--预计完成 日期控件 -->
    <el-form-item prop="deloy_finish" label="预计完成" label-width="100px" label-position="right">
      <el-date-picker style="width: 100%" v-model="form.deloy_finish" clearable type="datetime"
        placeholder="请选择预计完成" format="YYYY-MM-DD HH:mm:ss" value-format="YYYY-MM-DD HH:mm:ss" 
         :default-time="new Date($theia.str.dateFormat(new Date(),'yyyy/MM/dd 18:00:00'))"/>
    </el-form-item>
    </el-col>
    <el-col :span="12">
    <!-- {"index":127,"raw":"deloy_duration","name":"deloy_duration","cname":"DeloyDuration","type":{"raw":"varchar2(32)","name":"varchar2","len":32,"dlen":0},"defValue":"","allowNull":false,"constraints":["l","le","c","u","v","color"],"desc":{"raw":"时长(小时)","name":"时长(小时)"}} -->
    <!--时长(小时) 输入控件 -->
    <el-form-item prop="deloy_duration" label="时长(小时)" label-width="100px" label-position="right">
      <el-input clearable style="width: 100%" v-model="form.deloy_duration"  maxlength="32" 
      :rows="0"  placeholder="请输入时长(小时)"  />
      </el-form-item>
    </el-col>
    <el-col :span="12">
    <!-- {"index":128,"raw":"deloy_type","name":"deloy_type","cname":"DeloyType","type":{"raw":"number(2)","name":"number","len":2,"dlen":0},"defValue":"","allowNull":false,"constraints":["l","le","c","u","sl","tp(radio,c-u)","v","lw(120)","tp(tag,l)"],"desc":{"raw":"发布类型","name":"发布类型"}} -->
    <el-form-item prop="deloy_type" label="发布类型" label-width="100px" label-position="right">
      <el-radio-group v-model="form.deloy_type"   >
        <el-radio-button v-for="item in deloy_typeList" :key="item.value" :label="item.value" >
            {{item.name}}
        </el-radio-button>
      </el-radio-group>
    </el-form-item>
    </el-col>
    <el-col :span="24">
    <!-- {"index":129,"raw":"deloy_system","name":"deloy_system","cname":"DeloySystem","type":{"raw":"varchar2(128)","name":"varchar2","len":128,"dlen":0},"defValue":"","allowNull":false,"constraints":["le","c","u","sl(olb_system,-,#lob_id)","tp(cascader,c-u,multiple)","v"],"desc":{"raw":"发布系统","name":"发布系统"}} -->
     <!--发布系统 选择树 -->
     <el-form-item  label="发布系统" label-width="100px" label-position="right">
        <el-cascader ref="cascader_aaagp" style="width: 100%;"
        v-model="form.deloy_system" 
        placeholder="请选择发布系统"
        collapse-tags  collapse-tags-tooltip  clearable   :options="deloy_systemList"
        :props="{ multiple:true, children: 'children', label: 'name' }" />
    </el-form-item>
    </el-col>
    <el-col :span="12">
    <!-- {"index":130,"raw":"nmaster","name":"nmaster","cname":"Nmaster","type":{"raw":"varchar2(32)","name":"varchar2","len":32,"dlen":0},"defValue":"","allowNull":true,"constraints":["le","c","u","sl(dmaster,1,#lob_id)","tp(multicheck)","v"],"desc":{"raw":"前端","name":"前端"}} -->
    <!--前端 chckbox-group -->
    <el-form-item prop="nmaster" label="前端" label-width="100px" label-position="right">
      <el-checkbox-group v-model="form.nmaster"  >
      <el-checkbox-button v-for="item in nmasterList" :key="item.value" :label="item.value"  :value="item.value">
        {{item.name}}
        </el-checkbox-button>
      </el-checkbox-group>
      </el-form-item>
    </el-col>
    <el-col :span="12">
    <!-- {"index":131,"raw":"bmaster","name":"bmaster","cname":"Bmaster","type":{"raw":"varchar2(32)","name":"varchar2","len":32,"dlen":0},"defValue":"","allowNull":true,"constraints":["le","c","u","sl(dmaster,2,#lob_id)","tp(multicheck)","v"],"desc":{"raw":"后端","name":"后端"}} -->
    <!--后端 chckbox-group -->
    <el-form-item prop="bmaster" label="后端" label-width="100px" label-position="right">
      <el-checkbox-group v-model="form.bmaster"  >
      <el-checkbox-button v-for="item in bmasterList" :key="item.value" :label="item.value"  :value="item.value">
        {{item.name}}
        </el-checkbox-button>
      </el-checkbox-group>
      </el-form-item>
    </el-col>
    <el-col :span="12">
    <!-- {"index":132,"raw":"fmaster","name":"fmaster","cname":"Fmaster","type":{"raw":"varchar2(32)","name":"varchar2","len":32,"dlen":0},"defValue":"","allowNull":true,"constraints":["le","c","u","sl(dmaster,3,#lob_id)","tp(multicheck)","v"],"desc":{"raw":"流程","name":"流程"}} -->
    <!--流程 chckbox-group -->
    <el-form-item prop="fmaster" label="流程" label-width="100px" label-position="right">
      <el-checkbox-group v-model="form.fmaster"  >
      <el-checkbox-button v-for="item in fmasterList" :key="item.value" :label="item.value"  :value="item.value">
        {{item.name}}
        </el-checkbox-button>
      </el-checkbox-group>
      </el-form-item>
    </el-col>
    <el-col :span="12">
    <!-- {"index":133,"raw":"omaster","name":"omaster","cname":"Omaster","type":{"raw":"varchar2(32)","name":"varchar2","len":32,"dlen":0},"defValue":"","allowNull":true,"constraints":["l","le","c","u","sl(dmaster,5,#lob_id)","tp(multicheck)","v","show(m,l)","color"],"desc":{"raw":"部署","name":"部署"}} -->
    <!--部署 chckbox-group -->
    <el-form-item prop="omaster" label="部署" label-width="100px" label-position="right">
      <el-checkbox-group v-model="form.omaster"  >
      <el-checkbox-button v-for="item in omasterList" :key="item.value" :label="item.value"  :value="item.value">
        {{item.name}}
        </el-checkbox-button>
      </el-checkbox-group>
      </el-form-item>
    </el-col>
    <el-col :span="12">
    <!-- {"index":134,"raw":"tmaster","name":"tmaster","cname":"Tmaster","type":{"raw":"varchar2(32)","name":"varchar2","len":32,"dlen":0},"defValue":"","allowNull":true,"constraints":["l","le","c","u","sl(tmaster,-,#lob_id)","tp(multicheck)","v","lw(120)","tp(tag,l)"],"desc":{"raw":"测试验收","name":"测试验收"}} -->
    <!--测试验收 chckbox-group -->
    <el-form-item prop="tmaster" label="测试验收" label-width="100px" label-position="right">
      <el-checkbox-group v-model="form.tmaster"  >
      <el-checkbox-button v-for="item in tmasterList" :key="item.value" :label="item.value"  :value="item.value">
        {{item.name}}
        </el-checkbox-button>
      </el-checkbox-group>
      </el-form-item>
    </el-col>
    <el-col :span="12">
    <!-- {"index":135,"raw":"pmaster","name":"pmaster","cname":"Pmaster","type":{"raw":"varchar2(32)","name":"varchar2","len":32,"dlen":0},"defValue":"","allowNull":true,"constraints":["l","le","c","u","sl(pmaster,-,#lob_id)","tp(multicheck)","v","lw(120)","color"],"desc":{"raw":"产品验收","name":"产品验收"}} -->
    <!--产品验收 chckbox-group -->
    <el-form-item prop="pmaster" label="产品验收" label-width="100px" label-position="right">
      <el-checkbox-group v-model="form.pmaster"  >
      <el-checkbox-button v-for="item in pmasterList" :key="item.value" :label="item.value"  :value="item.value">
        {{item.name}}
        </el-checkbox-button>
      </el-checkbox-group>
      </el-form-item>
    </el-col>
    <el-col :span="12">
    <!-- {"index":136,"raw":"url","name":"url","cname":"Url","type":{"raw":"varchar2(62)","name":"varchar2","len":62,"dlen":0},"defValue":"","allowNull":false,"constraints":["le","c","u","rows(1)","v","tp(link,l-le-v)","v","tp(file,c-u)"],"desc":{"raw":"上线文档","name":"上线文档"}} -->
    <!--上线文档 文件控件 -->
    <el-form-item prop="url" label="上线文档" label-width="100px" label-position="right">
      <el-input clearable style="width: 100%" v-model="form.url"  maxlength="62" 
        :rows="1" 
        placeholder="请输入上线文档地址或上传文件"  >
        <template #append>
          <el-upload multiple :show-file-list="false" :action="conf.uploadPath" :limit="100" :on-success="onUploadSuccess" >
            <el-button type="primary">选择文件</el-button>
          </el-upload>
        </template>
      </el-input>
    </el-form-item>
    </el-col>
    <el-col :span="12">
    <!-- {"index":137,"raw":"status","name":"status","cname":"Status","type":{"raw":"number(2)","name":"number","len":2,"dlen":0},"defValue":"","allowNull":false,"constraints":["l","le","c","u","sl(deploy_status)","tp(radio,c-u)","color","tp(tag,l)","v","lw(60)"],"desc":{"raw":"状态","name":"状态"}} -->
    <el-form-item prop="status" label="状态" label-width="100px" label-position="right">
      <el-radio-group v-model="form.status"   >
        <el-radio-button v-for="item in statusList" :key="item.value" :label="item.value" >
            {{item.name}}
        </el-radio-button>
      </el-radio-group>
    </el-form-item>
    </el-col>
    <el-col :span="24">
    <!-- {"index":140,"raw":"effect_detail","name":"effect_detail","cname":"EffectDetail","type":{"raw":"varchar2(2000)","name":"varchar2","len":2000,"dlen":0},"defValue":"","allowNull":false,"constraints":["le","c","u","rows(2)","v"],"desc":{"raw":"发布风险","name":"发布风险"}} -->
    <!--发布风险 输入控件 -->
    <el-form-item prop="effect_detail" label="发布风险" label-width="100px" label-position="right">
      <el-input clearable style="width: 100%" v-model="form.effect_detail"  maxlength="2000" 
      :rows="2"  type="textarea" show-word-limit  placeholder="请输入发布风险"  />
      </el-form-item>
    </el-col>
    <el-col :span="24">
    <!-- {"index":141,"raw":"deloy_content","name":"deloy_content","cname":"DeloyContent","type":{"raw":"varchar2(2000)","name":"varchar2","len":2000,"dlen":0},"defValue":"","allowNull":false,"constraints":["le","q","c","u","rows(3)","v","#like"],"desc":{"raw":"发布内容","name":"发布内容"}} -->
    <!--发布内容 输入控件 -->
    <el-form-item prop="deloy_content" label="发布内容" label-width="100px" label-position="right">
      <el-input clearable style="width: 100%" v-model="form.deloy_content"  maxlength="2000" 
      :rows="3"  type="textarea" show-word-limit  placeholder="请输入发布内容"  />
      </el-form-item>
    </el-col>
    <el-col :span="24">
    <!-- {"index":142,"raw":"memo","name":"memo","cname":"Memo","type":{"raw":"varchar2(128)","name":"varchar2","len":128,"dlen":0},"defValue":"","allowNull":true,"constraints":["le","c","u","rows(1)","v"],"desc":{"raw":"说明","name":"说明"}} -->
    <!--说明 输入控件 -->
    <el-form-item prop="memo" label="说明" label-width="100px" label-position="right">
      <el-input clearable style="width: 100%" v-model="form.memo"  maxlength="128" 
      :rows="1"  type="textarea" show-word-limit  placeholder="请输入说明"  />
      </el-form-item>
    </el-col>
    </el-row>
</el-form>
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="hide" icon="close">取消</el-button>
        <el-button type="primary" @click="save" icon="select">提交</el-button>
      </span>
    </template>
  </el-dialog>
</template>

<script>
import rtext from "@/views/cmpnts/rtext.vue"
export default {
  components: {
    rtext
},
  data() {
    return {
      conf: {
        visible: false,
        width:this.$size.gt("m")?"50%":"70%",
        uploadPath:this.$theia.env.join("/file/upload"),
      },
      title:"修改上线部署",
rules_aaabz:{
    plan_id:[{required:true,message:"请输入上线计划",trigger: 'blur'}],
    deloy_version:[{required:true,message:"请输入版本",trigger: 'blur'}],
    name:[{required:true,message:"请输入名称",trigger: 'blur'}],
    deloy_start:[{required:true,message:"请输入预计开始",trigger: 'blur'}],
    deloy_finish:[{required:true,message:"请输入预计完成",trigger: 'blur'}],
    deloy_duration:[{required:true,message:"请输入时长(小时)",trigger: 'blur'}],
    deloy_type:[{required:true,message:"请输入发布类型",trigger: 'blur'}],
    deloy_system:[{required:true,message:"请输入发布系统",trigger: 'blur'}],
    nmaster:[{required:false,message:"请输入前端",trigger: 'blur'}],
    bmaster:[{required:false,message:"请输入后端",trigger: 'blur'}],
    fmaster:[{required:false,message:"请输入流程",trigger: 'blur'}],
    omaster:[{required:false,message:"请输入部署",trigger: 'blur'}],
    tmaster:[{required:false,message:"请输入测试验收",trigger: 'blur'}],
    pmaster:[{required:false,message:"请输入产品验收",trigger: 'blur'}],
    url:[{required:true,message:"请输入上线文档",trigger: 'blur'}],
    status:[{required:true,message:"请输入状态",trigger: 'blur'}],
    effect_detail:[{required:true,message:"请输入发布风险",trigger: 'blur'}],
    deloy_content:[{required:true,message:"请输入发布内容",trigger: 'blur'}],
    memo:[{required:false,message:"请输入说明",trigger: 'blur'}],
  },
    form:{
        plan_id:[],
        deloy_version:"",
        name:"",
        deloy_start:"",
        deloy_finish:"",
        deloy_duration:"",
        deloy_type:"",
        deloy_system:"",
        nmaster:[],
        bmaster:[],
        fmaster:[],
        omaster:[],
        tmaster:[],
        pmaster:[],
        url:"",
        status:"",
        effect_detail:"",
        deloy_content:"",
        memo:"",
    },
    plan_idList:[],
    deloy_typeList:[],
    deloy_systemList:[],
    nmasterList:[],
    bmasterList:[],
    fmasterList:[],
    omasterList:[],
    tmasterList:[],
    pmasterList:[],
    statusList:[],
    }
  },
  methods: {
    show(form) {
      this.conf.visible = true;
      this.loadEnums_aaabz()
      this.form = Object.assign(form,this.$route.params)
      this.get(form)
    },
      get(form){
        let that = this
        this.conf.loading = true
        let postForm = {}
        postForm.deploy_id = form.deploy_id
        this.$theia.http.get("/ws/dev/deploy",postForm).then(res=>{
          res.plan_id = (res.plan_id+"").split(",")
          res.nmaster = (res.nmaster+"").split(",")
          res.bmaster = (res.bmaster+"").split(",")
          res.fmaster = (res.fmaster+"").split(",")
          res.omaster = (res.omaster+"").split(",")
          res.tmaster = (res.tmaster+"").split(",")
          res.pmaster = (res.pmaster+"").split(",")
          that.form = Object.assign(that.form, res)
          let deloy_system = that.form.deloy_system.split(",")
          that.form.deloy_system = deloy_system
        //处理枚举重新绑定
          this.loadEnums_aaabz()
          that.conf.loading = false
        }).catch(res=>{
          let code = ((res||{}).response||{}).status||0
          let msg = `上线部署查询失败(${code})`
          that.$notify.error({title: '失败',message:msg ,duration:5000})
        })
    },
    save(){
        this.$refs.form.validate((v=>{
            if(v) this.onSave()
        }))
    },
    onSave(){
      let that = this
        let postForm = Object.assign({},this.form)
        postForm.plan_id = (postForm.plan_id||[]).join(",")
        let deloy_system = []
        let deloy_systemNodes = this.$refs.cascader_aaagp.getCheckedNodes() || []
        deloy_systemNodes.forEach(v => {
          deloy_system.push(v.value)
        })
        postForm.deloy_system = deloy_system.join(",")
        postForm.nmaster = (postForm.nmaster||[]).join(",")
        postForm.bmaster = (postForm.bmaster||[]).join(",")
        postForm.fmaster = (postForm.fmaster||[]).join(",")
        postForm.omaster = (postForm.omaster||[]).join(",")
        postForm.tmaster = (postForm.tmaster||[]).join(",")
        postForm.pmaster = (postForm.pmaster||[]).join(",")
        this.$theia.http.put("/ws/dev/deploy",postForm).then(res=>{
            that.$notify.success({title: '成功',message: '上线部署保存成功',duration:5000})
            that.hide()
            that.$emit("onsaved")
        }).catch(res=>{
            let code = ((res||{}).response||{}).status||0
            let msg = `上线部署修改失败(${code})`
            that.$notify.error({title: '失败',message: msg,duration:5000})
        })
    },
    hide() {
      this.conf.visible = false;
      this.$refs.form.resetFields();
    },
     onUploadSuccess(response){
      this.form.url = response.path
    },
    loadEnums_aaabz(){
        //上线计划
        this.plan_idList = this.$theia.enum.get("dev_plan","",this.$theia.user.get("lob_id"),false,"")
        //发布类型
        this.deloy_typeList = this.$theia.enum.get("deloy_type","","" ,false,"")
        //发布系统
        this.deloy_systemList = this.$theia.enum.getTree("olb_system","",this.$theia.user.get("lob_id"),99)
        //前端
        this.nmasterList = this.$theia.enum.get("dmaster","1",this.$theia.user.get("lob_id"),false,"")
        //后端
        this.bmasterList = this.$theia.enum.get("dmaster","2",this.$theia.user.get("lob_id"),false,"")
        //流程
        this.fmasterList = this.$theia.enum.get("dmaster","3",this.$theia.user.get("lob_id"),false,"")
        //部署
        this.omasterList = this.$theia.enum.get("dmaster","5",this.$theia.user.get("lob_id"),false,"")
        //测试验收
        this.tmasterList = this.$theia.enum.get("tmaster","",this.$theia.user.get("lob_id"),false,"")
        //产品验收
        this.pmasterList = this.$theia.enum.get("pmaster","",this.$theia.user.get("lob_id"),false,"")
        //状态
        this.statusList = this.$theia.enum.get("deploy_status","","" ,false,"")
    },

  },
};
</script>

<style scoped>
.form_item_info{
  margin-left: 4px;
  color:#999;
}
.form_item_info:hover{
  cursor: pointer;
  font-weight: 500;
  color:#333;
}
</style>